package com.ado.bazinga.core.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.ado.bazinga.core.dal.entity.Good;
import com.ado.bazinga.core.manager.GoodManager;
import com.ado.bazinga.core.service.GoodService;

/**
 *@author adonais
 *@date 2020年3月26日
 *@description GoodServiceImpl.java
**/
@Service(value = "goodService")
public class GoodServiceImpl implements GoodService {
	
	@Autowired
	@Qualifier(value = "goodManager")
	private GoodManager goodManager ;

	@Override
	public boolean createGood(Good good) {
		boolean flag = goodManager.save(good) ;
		return flag;
	}

	@Override
	public boolean updateGood(Good good) {
		boolean flag = goodManager.updateById(good);
		return flag;
	}

	@Override
	public boolean deleteGood(Integer id) {
		boolean flag = goodManager.removeById(id) ;
		return flag;
	}

	@Override
	public List<Good> getGoods() {
		List<Good> goods = goodManager.list() ;
		return goods;
	}

	@Override
	public Good getGoodById(Integer id) {
		Good good = goodManager.getById(id) ;
		return good;
	}

	@Override
	public List<Good> getAllGoods() {
		List<Good> goods = new ArrayList<Good>();
		goods = goodManager.list() ;
		return goods;
	}

	@Override
	public Integer countSoldNum() {
		Integer soldNum = goodManager.countSoldNum() ;
		return soldNum;
	}

	@Override
	public Integer countStockNum() {
		Integer stockNum = goodManager.countStockNum() ;
		return stockNum;
	}

	@Override
	public List<Good> findGoodsByType(String type) {
		List<Good> goods = goodManager.findGoodsByType(type) ;
		return goods;
	}
	
	

}
